<?php

if (isset($config)) {
	if (checkAdminPrivilege()) redirectUrl("index.php");

	if (isset($_POST["login"])) {
		$user = $_POST["username"];
		$pass = $_POST["password"];
		
		if (checkLogin($user, $pass)) {
			enableAdminPrivilege();
			redirectUrl("index.php");
		} else {
			redirectUrl("index.php?action=view&page=" . $config["special_page_prefix"] . $config["login_error_page"]);
		}
	} else {
		$loadTime = getTick();

		$pageTitle = $config["page_title"] . " | Login";
		
		$pageMenu = getPageContent($config["special_page_prefix"] . $config["menu_page"]);
		$pageSideMenu = getPageContent($config["special_page_prefix"] . $config["menu_side_page"]);
		
		$loadTime = getTick() - $loadTime;
		$pageInfo = formatPageInfo("", "", $loadTime);
		
		include(  $config["theme_dir"] . "/"
				. $config["theme"] . "/"
				. $config["theme_login"] . ".html" );
	}
} else {
	include("function.php");
}

?>